package cn.dianhun.om.jpa.utills;




public class ResultVOUtil {
    public static ResultVO success() {
        return success(ResultEnum.SUCCESS.getMessage());
    }

    public static <T> ResultVO<T> success(String message) {
        return success(null, message);
    }

    public static <T> ResultVO<T> successWith(T data) {
        return success(data, ResultEnum.SUCCESS.getMessage());
    }

    public static ResultVO error() {
        return error(ResultEnum.ERROR.getCode(), null, ResultEnum.ERROR.getMessage());
    }

    public static ResultVO error(String message) {
        return error(ResultEnum.ERROR.getCode(), null, message);
    }

    public static ResultVO error(Integer code, String message) {
        return error(code, null, message);
    }

    public static <T> ResultVO<T> errorWith(T data) {
        return error(ResultEnum.ERROR.getCode(), data, ResultEnum.ERROR.getMessage());
    }

    public static ResultVO error(ResultEnum resultEnum) {
        return error(resultEnum.getCode(), null, resultEnum.getMessage());
    }

    public static <T> ResultVO<T> success(T data, String message) {
        ResultVO<T> resultVO = new ResultVO<>();
        resultVO.setCode(ResultEnum.SUCCESS.getCode());
        resultVO.setData(data);
        resultVO.setMessage(message);
        return resultVO;
    }

    public static <T> ResultVO<T> error(Integer code, T data, String message) {
        ResultVO<T> resultVO = new ResultVO<>();
        resultVO.setCode(code);
        resultVO.setData(data);
        resultVO.setMessage(message);
        return resultVO;
    }
}
